<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>v-once指令</title>
    <script type="text/javascript" src="./../vue.js/vue.js"></script>
  </head>

  <body>
    <div id="root">
      <h2 v-once>初始化的n值是:{{n}}</h2>
      <h2>当前的n值是:{{n}}</h2>
      <button @click="n++">点我n+1</button>
    </div>

    <script type="text/javascript">
      Vue.config.productionTip = false;

      new Vue({
        el: "#root",
        data: {
          n: 1,
        },
      });
    </script>
  </body>
</html>

<!-- 
	v-once指令:
				1.v-once所在节点在初次动态渲染后,就视为静态内容了.
				2.以后数据的改变不会引起v-once所在结构的更新,可以用于优化性能.
-->
